Parse ICU message strings to a compact ast
Turns a ICU Message Format string:
`You have {
numBananas, plural,
=0 {no bananas}
one {a banana}
other {# bananas}
} for sale`
into a compact format-message ast:
[ "You have ", [ "numBananas", "plural", 0, {
"=0": [ "no bananas" ],
"one": [ "a banana" ],
"other": [ [ '#' ], " bananas" ]
} ], " for sale." ]
Quick Examples
npm install format-message-parse --save
import parse from 'format-message-parse'
import interpret from 'format-message-interpret'
interpret('en', parse('Hello, {name}!'))({ name: 'Jane' })
API
parse(pattern)
Generate an ast from a string pattern
License
This software is free to use under the MIT license. See the LICENSE-MIT file for license text and copyright information.